package com.aids_malaria.adapter;


import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.aids_malaria.R;
import com.aids_malaria.base.BaseQuickAdapter;
import com.aids_malaria.base.BaseViewHolder;
import com.aids_malaria.http.response.Pad;

import java.util.List;

public class PadManagerAdapter extends BaseQuickAdapter<Pad> {

    private PadManagerAdapter.Option mOption;

    public PadManagerAdapter(Context context, int layoutResID, List<Pad> data, Option option) {
        this(context, layoutResID, data);
        this.mOption = option;
    }

    public PadManagerAdapter(Context context, int layoutResID, List<Pad> data) {
        super(context, layoutResID, data);
    }

    @Override
    public void convert(BaseViewHolder holder, Pad item) {
        if (holder.getAdapterPosition() % 2 > 0){
            holder.getView(R.id.item).setBackgroundColor(mContext.getResources().getColor(R.color.c_item2));
        }else {
            holder.getView(R.id.item).setBackgroundColor(mContext.getResources().getColor(R.color.c_item1));
        }
        TextView status = (TextView) holder.getView(R.id.regist_state);
        status.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mOption.onItemclick(holder.getAdapterPosition());
            }
        });
        holder.setText(R.id.regist_state,item.getIs_check() == 0?"x":"✓");
        holder.setText(R.id.seq,item.getSeq());
        holder.setText(R.id.pad_id,item.getPad_id());
        holder.setText(R.id.memo,item.getMemo());
    }

    public interface Option{
        void onItemclick(int position);
    }

}
